package com.itlong.cloud.property;

import com.itlong.cloud.equip.property.IDeviceMediaInfoServiceClient;
import com.itlong.cloud.thrown.DataAccessException;
import com.itlong.cloud.utils.date.DateUtil;
import org.slf4j.Logger;import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.RestController;

import java.util.Calendar;

/**
 * <desc>
 *      物业-多媒体资源管理-定期查找过期多媒体资源
 * </desc>
 *
 * @createDate 2018-04-10.
 */
@EnableScheduling // 启用定时任务
@RestController
public class DeviceMediaPublishStatusTimedTask {

    private static Logger LOG = LoggerFactory.getLogger(DeviceMediaPublishStatusTimedTask.class);

    @Autowired
    private IDeviceMediaInfoServiceClient iDeviceMediaInfoServiceClient;

    /**
     * <desc>
     *     定时检测过期多媒体资源并置对应状态和定时发布多媒体资源
     * </desc>
     *
     * @param
     * @return
     * @author wangzhi
     * @createDate 2018-04-10
     */
    @Scheduled(cron = "0 * * * * ?") // 每一分钟触发一次
    public void checkAndChangeOverMediaPublishStatusTask(){
        try {
            iDeviceMediaInfoServiceClient.checkAndChangeOverMediaPublishStatusTask();
        } catch (Exception e) {
            throw new DataAccessException("【定时检测过期多媒体资源】检测过期多媒体资源并改变发布状态失败", e);
        }
    }

}
